import 'package:dio/dio.dart';
import 'package:dio_cache_interceptor/dio_cache_interceptor.dart';

import '../../tools/index.dart';

class EgApis {
  /// 加载列表数据
  loadListData({
    int page = 1,
    int? lastPostId,
    bool isShowLoad = false,
  }) async {
    Map<String, dynamic> data = {
      "page": page,
      "type": "loadmore",
    };
    if (lastPostId != null) {
      data = {
        "post_id": lastPostId,
        "page": page,
        "type": "loadmore",
      };
    }
    return await request(
      path: "/tc/list",
      data: data,
      isShowLoad: isShowLoad,
      isShowError: false,
      method: Method.get,
      policy:
          isShowLoad ? CachePolicy.refreshForceCache : CachePolicy.forceCache,
      options: Options(
        sendTimeout:
            lastPostId != null ? const Duration(milliseconds: 3000) : null,
      ),
    );
  }
}
